package KASystem;

import java.io.Serializable;
import java.util.Date;

/*
 * HETTA ER EIN KLASSI HJÁ KRISTJAN @author Kristjan
 */
class Participant implements Serializable {

    private String name;
    private String address;
    private String city;
    private String country;
    private String phone;
    private String arrival;
    private String departure;
    private Company company;
    private boolean speaker;
    private Companion companion;
    private HotelRoom hotelRoom;
    private Conference conference;
    private boolean roomOption;

    public Participant(String n, Conference c) {
        name = n;
        address = "";
        city = "";
        country = "";
        phone = "";

        arrival = null;
        departure = null;

        company = null;

        speaker = false;

        companion = null;

        hotelRoom = null;

        conference = c;

        roomOption = false;
    }
    
    public Companion getCompanion() {
        return companion;
    }
    
    public boolean hasCompanion(){
        if(companion == null){
            return false;
        } else {
            return true;
        }
    }

    public boolean getRoomOption() {
        return roomOption;
    }

    public int getPrice() {
        int finalPrice = 0;
        if (!isSpeaker()) {
            finalPrice += conference.getPrice();
        }

        if (companion != null) {
            finalPrice += companion.getPrice();
        }

        if (hotelRoom != null) {
            finalPrice += hotelRoom.getPrice();
        }


        return finalPrice;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * @param country the country to set
     */
    public void setCountry(String country) {
        this.country = country;
    }

    /**
     * @param phone the phone to set
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * @param arrival the arrival to set
     */
    public void setArrival(String arrival) {
        this.arrival = arrival;
    }

    /**
     * @param departure the departure to set
     */
    public void setDeparture(String departure) {
        this.departure = departure;
    }

    /**
     * @param company the company to set
     */
    public void setCompany(Company company) {
        this.company = company;
    }

    /**
     * @param speaker the speaker to set
     */
    public void setSpeaker(boolean speaker) {
        this.speaker = speaker;
    }

    /**
     * @param companion the companion to set
     */
    public void setCompanion(Companion companion) {
        this.companion = companion;
    }

    /**
     * @param hotelRoom the hotelRoom to set
     */
    public void setHotelRoom(HotelRoom hotelRoom) {
        this.hotelRoom = hotelRoom;
        this.hotelRoom.setParticipant(this);
    }

    /**
     * @param roomOption the roomOption to set
     */
    public void setRoomOption(boolean roomOption) {
        this.roomOption = roomOption;
    }
    
    public String toString() {
        
        String txt ="";
        String txt2 = "";
        
        if(speaker)
        {
            txt += "Yes";
        } else{
            txt += "No";
        }
        
        
        if(companion != null)
        {
            txt2 += companion.toString();
        }
        else{
            txt2 += "No companion";
        }
        
        
        
        String finalString = "Name: " + name + "\n";
        finalString += "Speaker: " + speaker + "\n";
        finalString += "Price: " + getPrice() + "\n";
        finalString += "Adress: " + address + "\n";
        finalString += "City: " + city + "\n";
        finalString += "Country: " + country + "\n";
        finalString += "Phone: " + phone + "\n";
        finalString += "Arrival: " + arrival + "\n";
        finalString += "Departure: " + departure + "\n";
        
        try{
        finalString += "Company: " + company.getName() + "\n";
        finalString += "Company: " + company.getPhone() + "\n";
        } catch (Exception ex){
            
        }
        
        finalString += "Speaker: " + txt + "\n\n";
        finalString += "Companion: " + txt2 + "\n";
        
        if(companion != null)
        {
             finalString += "Companion Trips:\n" + companion.getTripString();
        }
        
    
        
        return finalString;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @return the country
     */
    public String getCountry() {
        return country;
    }

    /**
     * @return the phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * @return the arrival
     */
    public String getArrival() {
        return arrival;
    }

    /**
     * @return the departure
     */
    public String getDeparture() {
        return departure;
    }

    /**
     * @return the speaker
     */
    public boolean isSpeaker() {
        return speaker;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
}
